package net.pugsplace.gpremacy.state;

import java.util.Collection;
import java.util.Vector;

import net.pugsplace.gpremacy.rules.Territory;
import net.pugsplace.gpremacy.rules.UnitType;

public class AbstractTerritory implements Territory {
	private static final long serialVersionUID = 5228261228651538253L;

	private String type;
	private String name;
	private int ownerCountryId;
	private long territoryId;
	private final Vector<UnitType> units;

	public AbstractTerritory() {
		units = new Vector<UnitType>();
	}

	public void addUnit(UnitType u) {
		units.add(u);
	}

	public String getName() {
		return name;
	}

	public int getOwnerCountryId() {
		return ownerCountryId;
	}

	public long getTerritoryId() {
		return territoryId;
	}

	public String getType() {
		return type;
	}

	public Collection<UnitType> getUnits() {
		return new Vector<UnitType>(units);
	}

	public void removeUnit(UnitType u) {
		units.remove(u);
	}

	public void setName(String name) {
		this.name = name;
	}

	public void setOwnerCountryId(int ownerCountryId) {
		this.ownerCountryId = ownerCountryId;
	}

	public void setTerritoryId(long territoryId) {
		this.territoryId = territoryId;
	}

	public void setType(String type) {
		this.type = type;
	}

	@Override
	public String toString() {
		return name + " (" + territoryId + ") owned by " + ownerCountryId;
	}
}
